#!/usr/bin/env python
#coding:utf-8
import pymongo

file_object = open('症状','r')
try:
    all_the_text = file_object.readlines()
finally:
     file_object.close( )

for line in all_the_text:
    zz = line[1:][:-1].replace("'",'').replace(" ",'').split(',')

db= pymongo.MongoClient('127.0.0.1',27017).yao
#遍历所有症状的类型，并进行相关处理
count = len(zz)
for z in range(count):
    if zz[z].find('反复') != -1:
        zz[z] = zz[z].replace('反复','')
    res = db.drug.update({"$or":[{'effect':{'$regex':zz[z]}},{'major_cure':{'$regex':zz[z]}}]},{'$addToSet':{"symptoms":zz[z]}},multi=True)
    print(res)


